/*
 * 9.6.cpp 1979_poj
 *
 *  Created on: 2012-5-21
 *      Author: jawinton
 */

#include <iostream>
#include <cstring>
#include <cstdio>

#define SIZE 22

char bricks[SIZE][SIZE];
int w, h;

int fn (int x, int y) {
	if (x < 0 || x > h-1 || y < 0 || y > w-1) return 0;
	if (bricks[x][y] == '#') return 0;
	bricks[x][y] = '#';
	return 1 + fn (x+1, y) + fn(x, y+1) +fn(x-1, y) + fn(x, y-1);
}

int main (void) {
	while (scanf("%d %d", &w, &h) && w != 0) {
		int x, y;
		for (int i=0; i<h; i++)
			scanf("%s", bricks[i]);
		for (int i=0; i<h; i++) {
			for (int j=0; j<w; j++) {
				if (bricks[i][j] == '@') {
					printf("%d\n", fn(i, j));
					break;
				}
			}
		}
	}
	return 0;
}
